int height_mm;
char * output_name;
char * manufacturer;
+ int refresh_rate;
};
G_DEFINE_TYPE (GdkWaylandScreen, _gdk_wayland_screen, GDK_TYPE_SCREEN)
monitor->geometry.width = width;
monitor->geometry.height = height;
+ monitor->refresh_rate = refresh;
g_signal_emit_by_name (monitor->screen, "monitors-changed");
update_screen_size (monitor->screen);
}
}
}
+
+int
+_gdk_wayland_screen_get_output_refresh_rate (GdkScreen *screen,
+ struct wl_output *output)
+{
+ GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
+ int i;
+
+ for (i = 0; i < screen_wayland->monitors->len; i++)
+ {
+ GdkWaylandMonitor *monitor = screen_wayland->monitors->pdata[i];
+
+ if (monitor->output == output)
+ return monitor->refresh_rate;
+ }
+
+ return 0;
+}
GdkCursor *cursor;
+ /* The wl_outputs that this window currently touches */
+ GSList *outputs;
+
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
unsigned int mapped : 1;
{
GdkWindow *window = data;
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+ GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkFrameClock *clock = gdk_window_get_frame_clock (window);
GdkFrameTimings *timings;
if (timings == NULL)
return;
+ timings->refresh_interval = 16667; /* default to 1/60th of a second */
+ if (impl->outputs)
+ {
+ /* We pick a random output out of the outputs that the window touches
+ * The rate here is in milli-hertz */
+ int refresh_rate = _gdk_wayland_screen_get_output_refresh_rate (wayland_display->screen,
+ impl->outputs->data);
+ if (refresh_rate != 0)
+ timings->refresh_interval = G_GINT64_CONSTANT(1000000000) / refresh_rate;
+ }
+
timings->complete = TRUE;
#ifdef G_ENABLE_DEBUG
}
}
+static void
+surface_enter (void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *output)
+{
+ GdkWindow *window = GDK_WINDOW (data);
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ impl->outputs = g_slist_prepend (impl->outputs, output);
+}
+
+static void
+surface_leave (void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *output)
+{
+ GdkWindow *window = GDK_WINDOW (data);
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ impl->outputs = g_slist_remove (impl->outputs, output);
+}
+
static void
shell_surface_handle_configure(void *data,
struct wl_shell_surface *shell_surface,
wl_shell_surface_pong(shell_surface, serial);
}
+static const struct wl_surface_listener surface_listener = {
+ surface_enter,
+ surface_leave
+};
+
static const struct wl_shell_surface_listener shell_surface_listener = {
shell_surface_ping,
shell_surface_handle_configure,
impl->surface = wl_compositor_create_surface (display_wayland->compositor);
wl_surface_set_user_data(impl->surface, window);
+ wl_surface_add_listener(impl->surface,
+ &surface_listener, window);
}
static void
{
wl_surface_destroy(impl->surface);
impl->surface = NULL;
+
+ g_slist_free (impl->outputs);
+ impl->outputs = NULL;
}
impl->shell_surface = NULL;
cairo_surface_destroy(impl->server_surface);